#
#    Copyright 2007 Andrew Wilkinson <andrew@indiegigs.co.uk>.
#
#    This file is part of Transport Manager (http://code.google.com/p/transportmanager/)
#
#    Transport Manager is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2.0 of the License, or
#    (at your option) any later version.
#
#    Transport Manager is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Lesser General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Transport Manager; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

from PyQt4 import QtCore, QtGui,  QtSvg

class Tile(object):
    def __init__(self, x, y):
        self.x, self.y = x, y
        self.angle = 0

        self.above = None
        self.below = None

    def __get_lowest(self):
        return self if self.below is None else self.below.lowest
    lowest = property(__get_lowest)

    def __get_highest(self):
        return self if self.above is None else self.above.highest
    highest = property(__get_highest)

class ImageTile(Tile,  QtGui.QGraphicsPixmapItem):
    def __init__(self, x, y, sprite):
        QtGui.QGraphicsPixmapItem.__init__(self, gfxcache[sprite])
        Tile.__init__(self, x, y)

        self.setParentItem(world)
        self.setPos(self.x, self.y)
        self.scale(1.0/32, 1.0/32)

class SvgTile(Tile,  QtSvg.QGraphicsSvgItem):
    def __init__(self, x, y, svg_file):
        QtSvg.QGraphicsSvgItem.__init__(self)
        Tile.__init__(self, x, y)

        self.setSharedRenderer(gfxcache[svg_file])

        self.setParentItem(world)
        self.setPos(self.x, self.y)
        self.scale(1.0/32, 1.0/32)
